package com.itheima.mapper.admin;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.itheima.domian.Dish;
import com.itheima.domian.vo.QueryVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author 12441
 * @Date 2022/8/11 15:11
 * @Version 1.0
 */
@Mapper
public interface DishMapper extends BaseMapper<Dish> {
//    @Insert("INSERT INTO dish ( dish_id, name, price, image, " +
//            "description, category_id,create_time, " +
//            "update_time, create_user, update_user)values (null,#{name},#{price},#{image}," +
//            "#{description},#{cateGoryId},#{createTime},#{updateTime}," +
//            "#{createUser},#{updateUser})")
//    Integer addDish(Dish dish);

//    @Select("SELECT category_id as categoryId, type, dish.name, dish.id, price,dish.code, image,dish.status,dish.sort," +
//            "dish.update_time as updateTime ,category.name as categoryName  FROM dish join category on dish.category_id = category.id")
    @Select("SELECT dish.id as id, type, dish.name, category_id as categoryId, price,dish.code, image,dish.status,dish.sort," +
            "dish.update_time as updateTime ,category.name as categoryName  FROM dish join category on dish.category_id = category.id")
    IPage<QueryVo> findByPage(IPage<QueryVo> page, @Param(Constants.WRAPPER) QueryWrapper<QueryVo> wrapper);


}
